function readFile(req, res, next) {
  function findSync(startPath) {
    let result = [];
    const etextedArr = [
      "REDMIN.md",
      "package.json",
      "node_modules",
      "yarn.lock",
      "index.html",
      "index.js",
    ];
    function finder(paths) {
      let files = fs.readdirSync(paths);
      files.forEach((val, index) => {
        let fPath = path.resolve(paths, val);
        let stats = fs.statSync(fPath);
        if (etextedArr.indexOf(val) == "-1") {
          if (stats.isDirectory()) finder(fPath);
          if (stats.isFile())
            result.push((fPath + "").split(__dirname).join(""));
        }
      });
    }
    finder(startPath);
    return result;
  }

  let fileNames = findSync(__dirname).map((item, index) => {
    return {
      date: item,
      id: Date.now() + index,
      name: "admin",
    };
  });
  let DataList = [
    {
      name: "接口查询",
      path: "/apiList",
      id: Date.now(),
      children: fileNames,
    },
  ];
  res.json({
    data: DataList,
    code: 200,
  });
}

module.exports = {
  path:'/readFile',
  function:readFile,
  method:'get'
};
